package com.yundong.gongchengji.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yundong.gongchengji.base.BaseFragment;

import java.util.List;

/**
 *
 * 该类用于 tablayout
 * Created by ls on 2016/10/20.
 */
public class MyPagerAdapter extends FragmentPagerAdapter {
    private  List<String> mTitleList;
    private List<BaseFragment> views;
    //通过构造方法传值
    public MyPagerAdapter(FragmentManager fm, List<String> mTitleList, List<BaseFragment> views) {
        super(fm);
        this.mTitleList=mTitleList;
        this.views=views;
    }

    @Override
    public Fragment getItem(int position) {
        return views.get(position);//获取当前的fragment
    }

    @Override
    public int getCount() {
        return views.size();
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleList.get(position); //获取tab标题
    }
}
